<include file="public@header"/>
<style>
.data-info-container{
    display: flex;
}
.data-info-container-left{
    flex: 1;
}
.data-info-container-right{
    flex: 2;
    margin-left: 20px;
}
</style>
</head>
<body>

<div class="wrap">
     <div class="data-info-container">
         <div class="data-info-container-left">
             <div class="panel panel-info">
                 <div class="panel-heading">
                     <h3 class="panel-title">共计 API 请求数</h3>
                 </div>
                 <div class="panel-body">
                     <h2>{$count_num}</h2>
                 </div>
             </div>
             <div class="panel panel-info">
                 <div class="panel-heading">
                     <h3 class="panel-title">本月 API 请求数</h3>
                 </div>
                 <div class="panel-body">
                     <h2>{$month_num}</h2>
                 </div>
             </div>
             <div class="panel panel-info">
                 <div class="panel-heading">
                     <h3 class="panel-title">本周 API 请求数</h3>
                 </div>
                 <div class="panel-body">
                     <h2>{$week_num}</h2>
                 </div>
             </div>
             <div class="panel panel-info">
                 <div class="panel-heading">
                     <h3 class="panel-title">今天 API 请求数</h3>
                 </div>
                 <div class="panel-body">
                     <h2>{$day_num}</h2>
                 </div>
             </div>
         </div>
         <div class="data-info-container-right">
             <div id="main" style="height:400px;"></div>
         </div>
     </div>
</div>
<script src="__STATIC__/js/admin.js?v={$_static_version}"></script>
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.2/dist/echarts.min.js"></script>
<script type="text/javascript">
    //页面加载事件
    $(function (){
        $.ajax({
            url:"{:url('Main/chart')}",
            success:function (res){
                var myChart = echarts.init(document.getElementById('main'));

                // 指定图表的配置项和数据
                var option = {
                    title: {
                        text: '近 7 天 API请求走势图'
                    },
                    tooltip: {
                        trigger: 'axis',   //鼠标经过提示
                    },
                    xAxis: {
                        type: 'category',
                        data: res.data.days
                    },
                    yAxis: {
                        type: 'value'
                    },
                    series: [
                        {
                            data: res.data.counts,
                            type: 'line'
                        }
                    ]
                };
                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option);
            },
            error:function () {
                alert(456)
            }
        })
    });
</script>
</body>
</html>